/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Animation.Animations;

import Scenery.BaseSprite;
import main.DumbMath;
import com.jme3.math.Matrix3f;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import Animation.Animation;
import Animation.Animation;
import Scenery.BaseCharacter;
import Scenery.BaseSprite;
import main.DumbMath;

/*
 * 
 * @author: Ziden
 * 
 */

public class ChestTurn extends Animation {

    public ChestTurn(BaseCharacter dude) {
        super(dude, 40);
        buildAnimation();
    }
    
    // BODY
    private Quaternion startRot;
    private float bodyRot = 0f;
    private float bodyRotSpeed = 0.13f;

    public void chestBounce() {
    }

    @Override
    public void gotoInitialState() {
        animationBody.getBodyNode().setLocalRotation(startRot);
        bodyRot = 0;
        frame = 0;
        bodyRotSpeed = 0.13f;
    }

    @Override
    public String getName() {
        return "ChestTurn";
    }

    @Override
    public void saveInitialState() {;
        startRot = animationBody.getBodyNode().getLocalRotation().clone();
    }

    @Override
    protected void buildFrame() {
       if(frame < maxFrame/4) // 10
           bodyRot = bodyRotSpeed;
       else if(frame >= maxFrame/4 && frame < (maxFrame*3)/4) // 30
           bodyRot = -bodyRotSpeed;
       else if(frame >= (maxFrame*3)/4)
           bodyRot = bodyRotSpeed;
       animationFrames[frame][0] = bodyRot;
    }

    @Override
    public void performFrame() {
        animationBody.getBodyNode().rotate(0, animationFrames[frame][0], 0);
    }

    @Override
    protected float getCicleRunTime() {
        return 0f;
    }
}
